# run:

# 	gcc test.c -o test.elf
# 	gcc patch-elf.c -std=gnu99 -o patch-elf
# 	# ./patch-elf test-32.elf
# 	# ./patch-elf test.elf func main c34889e5897dfc48
# 	./patch-elf test.elf addr 4004f1 c3
CFLAGS := -std=gnu99 -g


patch-elf: clean
	gcc $(CFLAGS) -DCOMPILE_ELF64 -c parse_elf.c -o parse_elf_elf64.o
	gcc $(CFLAGS) -DCOMPILE_ELF32 -c parse_elf.c -o parse_elf_elf32.o
	gcc $(CFLAGS) patch-elf.c parse_elf_elf32.o parse_elf_elf64.o -o patch-elf

test: patch-elf
	gcc -m32 test.c -o test-32.elf
	gcc -m64 test.c -o test-64.elf
	objdump -d test-64.elf > test-64.asm
	objdump -d test-32.elf > test-32.asm
	./patch-elf test-32.elf func main c3
	./patch-elf test-64.elf func main4 c3
	objdump -d test-64.elf > test-64.asm.1
	objdump -d test-32.elf > test-32.asm.1

clean:
	rm -f *.asm* *.elf *.o patch-elf

vcs: patch-elf
	./patch-elf vcs1 func vcs_checkout 31c0c3
